home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CUCD / Programming / OUI / palette.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  1.6 KB  |  61 lines

  1. // $Id: palette.cc 1.3 1998/01/13 20:01:29 dlorre Exp dlorre $
  2. #include <libraries/gadtools.h>
  3.  
  4. #include "gadgets/palette.h"
  5. #include "gadgetlist.h"
  6.  
  7. #include <proto/gadtools.h>
  8.  
  9. // ========================================================================
  10. // ===========================  PALETTE CLASS =============================
  11. // ========================================================================
  12.  
  13.  
  14. palette::palette(gadgetlist *gl,
  15.                 void (window::*func)(gadget *, unsigned long, unsigned short),
  16.                 const char *text,
  17.                 long depth,
  18.                 long offset,
  19.                 long pen,
  20.                 long place,
  21.                 short iwidth, short iheight) : gadget(gl, func)
  22. {
  23.     gl->ng->ng_Flags = place ;
  24.     gl->ng->ng_GadgetText = (UBYTE *)text ;
  25.     gad = gl->gad = (Gadget *)CreateGadget(PALETTE_KIND, gl->gad, gl->ng,
  26.         GTPA_Depth, depth,
  27.         GTPA_ColorOffset, offset,
  28.         GTPA_Color,     pen,
  29.         GTPA_IndicatorWidth, iwidth,
  30.         GTPA_IndicatorHeight, iheight,
  31.         GT_Underscore,  '_',
  32.         TAG_END) ;
  33. }
  34.  
  35. void palette::action(unsigned long classe, unsigned short code)
  36. {
  37.     cursel = code ;
  38.     gadget::action(classe, code) ;
  39. }
  40.  
  41. void palette::set(long sel)
  42. {
  43.     cursel = sel ;
  44.     GT_SetGadgetAttrs(gad, w, NULL,
  45.         GTPA_Color, cursel,
  46.         TAG_DONE) ;
  47. }
  48.  
  49. void palette::keystroke(BOOL shifted)
  50. {
  51.     if (shifted) {
  52.         if (cursel) cursel-- ;
  53.     }
  54.     else {
  55.         if (cursel < (numcolors-1)) cursel++ ;
  56.     }
  57.     gadget::action(NULL, cursel) ;
  58.     GT_SetGadgetAttrs(gad, w, NULL,
  59.         GTPA_Color, cursel,
  60.         TAG_DONE) ;
  61. }